

#include <stdio.h>
#include "VinH264NalUnit.h"






VinNalUnit::VinNalUnit ()
{
}
VinNalUnit::~VinNalUnit ()
{
}

nalUnit* VinNalUnit::GetNextNalUnit(UInt8* bitstream)
{
    nalUnit* theNalUnit = new nalUnit;

    if (theNalUnit == NULL) {
        return NULL;
    }

    theNalUnit->theNalHeader = (PNAL_HEADER) bitstream;

    UInt32 zeroCount = 0;
    UInt32 nalLength = 0;

    while (bitstream != NULL && !(*bitstream == 1 && zeroCount >= 3)) {

        switch (*bitstream) {
            case 0:
                zeroCount++;
                break;
            default:
                zeroCount = 0;
        }
        bitstream++;
        nalLength++;
    }

    theNalUnit->nalLength = nalLength - 1;
    theNalUnit->nalPayload = bitstream + 1;
}


void VinNalUnit::ParseNalUnit (nalUnit* theNalUnit)
{
    switch (theNalUnit->theNalHeader->nalUnitType) {
        case kNalUnitTypeSPS:
            break;
        case kNalUnitTypePPS:
            break;
        case kNalUnitTypeSEI:
            break;
        case kNalUnitTypeIDR:
            break;
        case kNalUnitTypeNonIDR:
            break;
        default:
            break;
    }
}